package com.newtouch.cq.security.config;


import cn.hutool.core.util.StrUtil;
import com.newtouch.cq.security.token.GenericTokenResolveAble;

import javax.servlet.http.HttpServletRequest;

@SuppressWarnings("serial")
public class GenericTokenResolveHeader implements GenericTokenResolveAble {


	public String resolveToken(HttpServletRequest request) {
		String auth_token = request.getHeader(MccOauth2Properties.tokenHeader);
		String auth_token_start = MccOauth2Properties.tokenStart;
		if (StrUtil.startWith(auth_token, auth_token_start)) {
			auth_token = auth_token.substring(auth_token_start.length());
		}
		return auth_token;
	}

}
